home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 52
/
Amiga Format AFCD52 (Issue 136, May 2000).iso
/
-in_the_mag-
/
multitasking
/
feature
/
executive_v2.10
/
executiveapi
/
executiveapi.doc
< prev
next >
Wrap
Text File
|
2000-03-02
|
9KB
|
267 lines
TABLE OF CONTENTS
ExecutiveAPI/--background--
ExecutiveAPI/--usage--
ExecutiveAPI/EXAPI_CMD_ADD_CLIENT
ExecutiveAPI/EXAPI_CMD_REM_CLIENT
ExecutiveAPI/EXAPI_CMD_GET_NICE
ExecutiveAPI/EXAPI_CMD_SET_NICE
ExecutiveAPI/--background-- ExecutiveAPI/--background--
PURPOSE
ExecutiveAPI is a simple, easy to use application program
interface to some Executive features. As you know, there are
programs that require an entry in Executive.prefs file to, for
example, keep task's priority above all scheduled tasks. They
assume that task priorities will remain unchanged, which is
ok although it's not guaranteed anywhere. With ExecutiveAPI,
it's possible to configure Executive directly from the application.
FEATURES
* Add/remove client
The purpose of this is to prevent Executive from exiting/
restarting while your program is running.
* Get/set nice-value
Easily get or set the nice-value of a task.
* Get priority
Because there is no GetTaskPri() function in exec.library, you
can't read task's real priority from task-structure while
Executive is running, because it may be the scheduling priority.
* Add entries to Executive's "watched" tasks list
Lets you control task scheduling directly without having
to add entries to Executive.prefs file.
AUTHOR
Petri Nordlund <petrin@megabaud.fi>
HISTORY
V1.00 First release
ExecutiveAPI/--usage-- ExecutiveAPI/--usage--
Communication with Executive is done trough a public message
port, "Executive_server". Simple command messages can be sent
to this port. The necessary steps to send a command are:
1. Initialize ExecutiveMessage structure
2. Send the message to the port
3. Wait for reply
4. Delete the message
The message, commands and possible errors are defined in
ExecutiveAPI.h file.
It's important that the "ident" item in ExecutiveMessage
structure is always initialized to 0, as this is used by
Executive to separate ExecutiveAPI messages and messages
from Executive client programs.
The "command" must always be given, "task", "taskname" and
"value1-4" items only if the command requires them.
"taskname" only works with EXAPI_CMD_WATCH command.
The "error" item will be zero if everything went well, otherwise
an error occurred.
The included example program demonstrates all ExecutiveAPI
commands.
Please don't hesitate to ask me about ExecutiveAPI usage.
My email address is <petrin@megabaud.fi>.
ExecutiveAPI/EXAPI_CMD_ADD_CLIENT ExecutiveAPI/EXAPI_CMD_ADD_CLIENT
NAME
EXAPI_CMD_ADD_CLIENT - Add a program as Executive client
FUNCTION
If you want to prevent Executive from exiting/restarting, make
your program an Executive client. As long as there are clients,
Executive can't quit.
This is useful if you add tasks to Executive's watched tasks
list with EXAPI_CMD_WATCH command, they'll disappear if the
server is restarted.
Remember to remove the client with EXAPI_CMD_REM_CLIENT command.
RESULT
error - non-zero if error
SEE ALSO
EXAPI_CMD_REM_CLIENT, <ExecutiveAPI.h>
ExecutiveAPI/EXAPI_CMD_REM_CLIENT ExecutiveAPI/EXAPI_CMD_REM_CLIENT
NAME
EXAPI_CMD_REM_CLIENT - Remove client
FUNCTION
Remove client added using EXAPI_CMD_ADD_CLIENT command.
RESULT
error - non-zero if error
SEE ALSO
EXAPI_CMD_ADD_CLIENT, <ExecutiveAPI.h>
ExecutiveAPI/EXAPI_CMD_GET_NICE ExecutiveAPI/EXAPI_CMD_GET_NICE
NAME
EXAPI_CMD_GET_NICE - Get task's nice-value
FUNCTION
Get task's nice-value.
INPUTS
task - task address
RESULT
error - non-zero if error
value1 - task's nice-value
SEE ALSO
EXAPI_CMD_SET_NICE, <ExecutiveAPI.h>
ExecutiveAPI/EXAPI_CMD_SET_NICE ExecutiveAPI/EXAPI_CMD_SET_NICE
NAME
EXAPI_CMD_SET_NICE - Set task's nice-value
FUNCTION
Set task's nice-value. Old nice-value is returned in "value1".
Allowed values are -20 to +20. Do not specify an illegal
value because Executive doesn't check the given nice-value.
You should always restore the old nice-value when your
program exits, if it can be run in a shell. Otherwise
the shell gets a wrong nice-value.
INPUTS
task - task address
value1 - new nice-value (-20 -- +20)
RESULT
error - non-zero if error
value1 - task's old nice-value
SEE ALSO
EXAPI_CMD_GET_NICE, <ExecutiveAPI.h>
ExecutiveAPI/EXAPI_CMD_GET_PRIORITY ExecutiveAPI/EXAPI_CMD_GET_PRIORITY
NAME
EXAPI_CMD_GET_PRIORITY - Get task's real priority
FUNCTION
Ask Executive to return the real (not the scheduling) priority
of the specified task. If the task is currently scheduled and
you read the priority directly from task-structure, it will be
somewhere in the dynamic range. There's no GetTaskPri() routine
in exec.library which could be patched to return the real
priority.
In a case a new task is launched with its parent task's priority,
which is in the dynamic range, Executive notices this, and sets
the new task's real priority to its parent task's real priority.
But if wish to create a childtask whose priority will be the
priority of the parent task plus one, and you read the priority
from task-structure, it might be something like -58. Add one to
this value, and you'll get -57. Executive can't correct this, so
in this case use the EXAPI_CMD_GET_PRIORITY command to obtain
task's real priority.
INPUTS
task - task address
RESULT
error - non-zero if error
value1 - task's real priority
SEE ALSO
<ExecutiveAPI.h>
ExecutiveAPI/EXAPI_CMD_WATCH ExecutiveAPI/EXAPI_CMD_WATCH
NAME
EXAPI_CMD_WATCH - Add entries to Executive's watched tasks list
FUNCTION
This command lets you add entries to Executive's watched task
list, which contains entries from Executive.prefs, for example:
TASK NComm NOSCHEDULE ABOVE
CHILDTASKS XiPaint RELATIVE
With this command you could add these entries directly from
the application. See ExecutivePrefs documentation for information
on what these entries do. Especially the RELATIVE option has some
restrictions, be sure you know them.
The value1, value2, value3 and value4 items in ExecutiveMessage
are used as follows:
value1 = EXAPI_TYPE_TASK
EXAPI_TYPE_CHILDTASKS
value2 = EXAPI_WHICH_SCHEDULE
EXAPI_WHICH_NOSCHEDULE -> value3 = EXAPI_PRI_LEAVE_ALONE
EXAPI_WHICH_RELATIVE EXAPI_PRI_BELOW
EXAPI_PRI_ABOVE
EXAPI_PRI_SET -> value4
(priority)
For example, the "CHILDTASKS XiPaint RELATIVE" entry would be:
msg->value1 = EXAPI_TYPE_CHILDTASKS
msg->value2 = EXAPI_WHICH_RELATIVE
You can either specify task address or task name. Use task
address if possible. Executive will duplicate the task name.
Wildcards (`*') are allowed in the name.
If XiPaint would send the message, it would initialize task
address:
msg->task = FindTask(NULL)
Executive doesn't check the values, so make sure you specify
all the necessary values. "value3" is used only with
EXAPI_WHICH_NOSCHEDULE. "value4" contains task priority if
EXAPI_PRI_SET is used. EXAPI_WHICH_RELATIVE naturally works
with EXAPI_TYPE_CHILDTASKS only.
You can issue an EXAPI_CMD_WATCH for a task when the task is
already running, but for childtasks you have to issue the
command before any childtasks have been started.
Once you have added an entry into the watched tasks list, you
can't remove it. It will stay there until Executive exits.
If you get EXAPI_ERROR_ALREADY_WATCHED error, it means that
there's already an entry for the specified task. It was either
added by your task if it was run before, or the entry is in
Executive.prefs file. In most cases you can safely ignore this
error.
There's no EXAPI_TYPE_TASK_CHILDTASKS, so use the same message
twice, just change EXAPI_TYPE_TASK to EXAPI_TYPE_CHILDTASKS and
resend the message.
INPUTS
task - task address, or NULL if you want to use task name
taskname - task name if task address isn't specified
value1 - task or childtasks
value2 - schedule, noschedule or relative
value3 - what to do with task's priority, used with
EXAPI_TYPE_NOSCHEDULE
value4 - set task's priority to this value, if EXAPI_PRI_SET
in value3
RESULT
error - non-zero if error
SEE ALSO
<ExecutiveAPI.h>